<template>
  <van-field
    v-bind="getWidgetProps"
    :readonly="true"
    :value="getWidgetText"
  >
    <template #input>
      <div v-if="isHtml" v-html="getWidgetText"></div>
      <div v-else>{{getWidgetText}}</div>
    </template>
  </van-field>
</template>

<script>
export default {
  name: 'onlineFieldlabel',
  props: {
    value: {
      type: [String, Number, Date, Boolean]
    },
    widget: {
      type: Object,
      required: true
    }
  },
  computed: {
    getWidgetProps () {
      return {
        label: this.widget.showName,
        required: this.widget.props.required
      }
    },
    getWidgetText () {
      return this.value;
    },
    isHtml () {
      return this.widget && this.widget.widgetType === this.SysCustomWidgetType.Text && this.widget.column && this.widget.column.isRichText;
    }
  }
}
</script>

<style>
</style>
